<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="Templates.aspx.cs" Inherits="Templates" Title="Templates" %>
<asp:Content ID="content2" ContentPlaceHolderID="phActions" runat="server">
    <asp:LinkButton ID="btnAddNewTemplate" Text="Add New Template" OnClick="btnAddNewTemplate_Click" runat="server" />
    <asp:LinkButton ID="btnSaveNewTemplate" Text="Save" OnClick="btnSaveNewTemplate_Click" CausesValidation="true" ValidationGroup="SaveNewTemplate" runat="server" />
    <asp:LinkButton ID="btnCancelNewTemplate" Text="Cancel" OnClick="btnCancelNewTemplate_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnAllTemplates" Text="Select Template" OnClick="btnAllTemplates_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnEditTemplate" Text="Edit Template" OnClick="btnEditTemplate_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnDeleteTemplate" Text="Delete Template" OnClientClick="javascript:return confirm('Are you sure you want to delete this template');" OnClick="btnDeleteTemplate_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnSaveTemplate" Text="Save" OnClick="btnSaveTemplate_Click" CausesValidation="true" ValidationGroup="SaveTemplate" runat="server" />
    <asp:LinkButton ID="btnCancelTemplate" Text="Cancel" OnClick="btnCancelTemplate_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnAddTemplateFile" Text="Add Template File" OnClick="btnAddTemplateFile_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnSaveTemplateFile" Text="Save" OnClick="btnSaveTemplateFile_Click" CausesValidation="true" ValidationGroup="SaveTemplateFile" runat="server" />
    <asp:LinkButton ID="btnCancelTemplateFile" Text="Cancel" OnClick="btnCancelTemplateFile_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnAddTemplateControl" Text="Add Template Control" OnClick="btnAddTemplateControl_Click" CausesValidation="false" runat="server" />
    <asp:LinkButton ID="btnSaveTemplateControl" Text="Save" OnClick="btnSaveTemplateControl_Click" CausesValidation="true" ValidationGroup="SaveTemplateControl" runat="server" />
    <asp:LinkButton ID="btnCancelTemplateControl" Text="Cancel" OnClick="btnCancelTemplateControl_Click" CausesValidation="false" runat="server" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="phMain" Runat="Server">
    <asp:PlaceHolder ID="phTemplates" runat="server">
        <fieldset style="width:auto;">
            <legend>Current Templates</legend>
            <asp:GridView ID="gvTemplates" runat="server" DataSourceID="dsTemplates" AutoGenerateColumns="False" DataKeyNames="Id,ConcurencyId" OnSelectedIndexChanged="gvTemplates_SelectedIndexChanged">
                <Columns>
                    <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" ReadOnly="true" />
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:CommandField ButtonType="Link" ShowSelectButton="true" />
                    <acms:CommandField ButtonType="Link" CommandName="Delete" Text="Delete" ConfirmMessage="Are you sure you want to delete this template?" />
                </Columns>
            </asp:GridView>
        </fieldset>
    </asp:PlaceHolder>
    <asp:PlaceHolder ID="phTemplateDetails" runat="server">
        <fieldset>
            <legend>Template Properties</legend>
            <asp:DetailsView ID="dvTemplate" runat="server" DataSourceID="dsTemplates" AutoGenerateRows="False" DataKeyNames="Id,ConcurencyId" AllowPaging="true" PagerSettings-Mode="NextPrevious" PagerSettings-NextPageText="&raquo;" PagerSettings-PreviousPageText="&laquo;" OnPageIndexChanged="dvTemplate_PageIndexChanged">
                <Fields>
                    <acms:TextBoxField HeaderText="Name" DataField="Name" Width="300px" MaxLength="250" Required="True" RequiredValidationGroup="SaveTemplate" />
                    <acms:TextAreaField HeaderText="Notes" DataField="Notes" Rows="10" Cols="75" MaxLength="2000" Required="False" />
                </Fields>
            </asp:DetailsView>
        </fieldset>
        <asp:PlaceHolder ID="phTemplateFiles" runat="server">
            <fieldset>
                <legend>Template Files</legend>
                <asp:GridView ID="gvTemplateFiles" DataSourceID="dsTemplateFiles" DataKeyNames="Id,ConcurencyId" AutoGenerateColumns="false" OnSelectedIndexChanged="gvTemplateFiles_SelectedIndexChanged" runat="server">
                    <Columns>
                        <asp:BoundField HeaderText="Name" DataField="Name"/>
                        <asp:BoundField HeaderText="Path" DataField="Path"/>
                        <asp:BoundField HeaderText="Master Page Path" DataField="MasterPagePath"/>
                        <asp:BoundField HeaderText="Theme" DataField="Theme"/>
                        <acms:RadioButtonField HeaderText="Default" DataField="IsDefault"/>
                        <asp:CommandField ShowSelectButton="true" ShowEditButton="false" SelectText="Edit" />
                        <acms:CommandField ButtonType="Link" CommandName="Delete" Text="Delete" ConfirmMessage="Are you sure you want to delete this Template File?" />
                    </Columns>
                </asp:GridView>
            </fieldset>
        </asp:PlaceHolder>
        <asp:PlaceHolder ID="phTemplateFileDetails" runat="server">
            <fieldset>
                <legend>Template File</legend>
                <asp:DetailsView ID="dvTemplateFileDetails" runat="server" DataSourceID="dsTemplateFiles" AutoGenerateRows="False" DataKeyNames="Id,ConcurencyId">
                    <Fields>
                        <acms:TextBoxField DataField="Name" MaxLength="50" HeaderText="Name" Required="true" RequiredValidationGroup="SaveTemplateFile"/>
                        <acms:TextBoxField Width="250px" MaxLength="255" Required="true" DataField="Path" RequiredValidationGroup="SaveTemplateFile" HeaderText="Path" />
                        <acms:TextBoxField Width="250px" MaxLength="255"  DataField="MasterPagePath" HeaderText="Master Page Path" />
                        <acms:TextBoxField MaxLength="50"  HeaderText="Theme" DataField="Theme"/>
                        <acms:CheckBoxField HeaderText="Default" AllowRemoveChecked="false" DataField="IsDefault" />
                    </Fields>
                </asp:DetailsView>
            </fieldset>
        </asp:PlaceHolder>
        <asp:PlaceHolder ID="phTemplateControls" runat="server">
            <fieldset>
                <legend>Template Controls</legend>
                <asp:GridView ID="gvTemplateControls" runat="server" AutoGenerateColumns="False" DataKeyNames="Id,ConcurencyId"
                    DataSourceID="dsTemplateProperties" EmptyDataText="There are currently no template controls set up." OnSelectedIndexChanged="gvTemplateControls_SelectedIndexChanged">
                    <Columns>
                        <asp:BoundField DataField="Name" HeaderText="Name" />
                        <asp:BoundField DataField="TypeName" HeaderText="Type" />
                        <asp:CommandField ShowSelectButton="true" SelectText="Edit" />
                        <acms:CommandField ButtonType="Link" CommandName="Delete" Text="Delete" ConfirmMessage="Are you sure you want to delete this Template Control?" />
                    </Columns>
                </asp:GridView>
            </fieldset>
        </asp:PlaceHolder>
        <asp:PlaceHolder ID="phTemplateControlDetails" runat="server">
            <fieldset>
                <legend>Template Control</legend>
                <asp:DetailsView ID="dvTemplateControl" runat="server" DataSourceID="dsTemplateProperties" AutoGenerateRows="false" DataKeyNames="Id,ConcurencyId">
                    <Fields>
                        <acms:TextBoxField Required="true" RequiredValidationGroup="SaveTemplateControl" DataField="Name" HeaderText="Name" SortExpression="Name" />
                        <asp:TemplateField HeaderText="Type" SortExpression="TypeId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="dsPropertyType"
                                    DataTextField="Name" DataValueField="Id" SelectedValue='<%# Bind("TypeId") %>'>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("TypeName") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                </asp:DetailsView>
            </fieldset>
        </asp:PlaceHolder>
    </asp:PlaceHolder>
    <asp:PlaceHolder ID="phAddNewTemplate" runat="server">
        <fieldset>
            <legend>Add New Template</legend>
            <asp:DetailsView ID="dvNewTemplate" runat="server" DataSourceID="dsTemplates" DefaultMode="Insert" AutoGenerateInsertButton="false" AutoGenerateRows="False" DataKeyNames="Id,ConcurencyId">
                <Fields>
                    <acms:TextBoxField DataField="Name" HeaderText="Name" Required="true" RequiredValidationGroup="SaveNewTemplate"/>
                    <asp:TemplateField HeaderText="Default File Path">
                        <InsertItemTemplate>
                            <asp:TextBox ID="txtFilePath" Width="250px" runat="server" />
                            <asp:RequiredFieldValidator ID="valFilePath" ControlToValidate="txtFilePath" ValidationGroup="SaveNewTemplate" Display="Dynamic" ErrorMessage="*Required" runat="server" />
                        </InsertItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
        </fieldset>
    </asp:PlaceHolder>
    <acms:TemplateDataSource ID="dsTemplates" runat="server" OnSelectData="dsTemplates_SelectData" OnUpdatingData="dsTemplates_UpdatingData" OnUpdatedData="dsTemplates_UpdatedData">
    </acms:TemplateDataSource>
    <acms:TemplateFileDataSource ID="dsTemplateFiles" runat="server" OnSelectData="dsTemplateFiles_SelectData" OnUpdatingData="dsTemplateFiles_UpdatingData"/>
    <acms:TemplateControlDataSource ID="dsTemplateProperties" runat="server" OnSelectData="dsTemplateProperties_SelectData" OnUpdatingData="dsTemplateProperties_UpdatingData"/>
    <acms:ControlTypeDataSource ID="dsPropertyType" runat="server" OnSelectData="dsPropertyType_SelectData"/>
</asp:Content>

